package com.yqz.sys.controller;

import com.yqz.common.base.controller.BaseController;
import com.yqz.common.util.WebUtil;
import com.yqz.sys.form.CompRoleForm;
import com.yqz.sys.query.CompRoleQuery;
import com.yqz.sys.service.CompRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("comp/role")
public class CompRoleController extends BaseController<CompRoleQuery, CompRoleForm> {

    @Autowired
    private CompRoleService roleService;

    public CompRoleController(CompRoleService roleService) {
        super(roleService);
    }

    @RequestMapping("list.do")
    public Object list(CompRoleQuery query){
        query.setCompId(WebUtil.getCurrentCompUser().getCompId());
        return roleService.queryAll(query);
    }

    @RequestMapping("setRolePerm.do")
    public Object setRolePerm(@RequestParam("rId") Integer rId,@RequestParam("pId") List<Integer> pId){
        return roleService.setRolePerm(rId,pId);
    }

}
